<?php

namespace App\model;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Model;

//录入商品
class AddMerchant extends Model
{

    protected $table = 'add_merchant';

    protected $guarded = [];

    //查询商品数量
	function getGoodsNumAttribute(){
        $num = DB::table('add_shop_cost')
        ->leftJoin('add_shop','add_shop.id','add_shop_cost.gid')
        ->leftjoin('add_merchant','add_merchant.id','add_shop_cost.mid')
        ->where('add_shop.status','<>',3)
        ->where('add_merchant.id',$this->id)
        ->count();
        
		return $num;
	}
}